package com.example.demo.mapper;

import com.example.demo.entity.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DepartmentMapper {
    @Select("SELECT * FROM department WHERE id = #{id}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "employees", column = "id", 
                many = @Many(select = "com.example.demo.mapper.EmployeeMapper.getEmployeesByDepartmentId"))
    })
    Department getDepartmentById(Integer id);

    @Select("SELECT * FROM department")
    List<Department> getAllDepartments();
}